﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Xml;
using System.Net;
using System.Text;
using System.IO;
using System.Collections.Generic;

/// <summary>
///淘宝api接口，关联dll：BS2.BSTaobaoAPI.dll，BS2.XML.dll
/// </summary>
public class TaoBaoAPI
{
    public TaoBaoAPI()
    {      
    }
    /// <summary>
    /// 获取Appkey
    /// </summary>
    public string GetAppKey(string username)
    {
        string sqlstring = "select appkey from tb_appcode where field1 is  not null and field2 = '" + username + "'";//根据淘宝用户名查询淘宝网AppKey
        DataSet ds = DBUtility.SqlHelper.Query(DBUtility.SqlHelper.LocalSqlServer, sqlstring);
        if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            return ds.Tables[0].Rows[0]["AppKey"].ToString();
        return "12005934";
    }
    /// <summary>
    /// 获取certCode
    /// </summary>
    public string GetCertCode(string username)
    {
        string sqlstring = "select AppCertCode from tb_appcode where field1 is  not null and field2 = '" + username + "'";//根据淘宝用户名查询淘宝网AppSecret
        DataSet ds = DBUtility.SqlHelper.Query(DBUtility.SqlHelper.LocalSqlServer, sqlstring);
        if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            return ds.Tables[0].Rows[0]["AppCertCode"].ToString();
        return "a28772bd734c8b52ba0d16e838bb8246";
    }
    /// <summary>
    /// 获取Appkey
    /// </summary>
    public string GetAppKey()
    {
        string sql = "select appkey from tb_appcode where isuse=1";
        DataSet ds = DBUtility.SqlHelper.Query(DBUtility.SqlHelper.LocalSqlServer, sql);
        if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            return ds.Tables[0].Rows[0][0].ToString();
        return "27627";
    }
    /// <summary>
    /// 获取certCode
    /// </summary>
    public string GetCertCode()
    {
        string sql = "select appcertcode from tb_appcode where isuse=1";
        DataSet ds = DBUtility.SqlHelper.Query(DBUtility.SqlHelper.LocalSqlServer, sql);
        if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            return ds.Tables[0].Rows[0][0].ToString();
       return "c2e5ed20406011deae718c0bea828c3d";
    }
   /// <summary>
    /// 通过向淘宝服务器post数据，实现自动登录，支持中文用户名
   /// </summary>
   /// <param name="username">用户名</param>
   /// <param name="password">密码</param>
   /// <param name="myCC">暂存cookie</param>
   /// <param name="errMsg">出错信息</param>
   /// <returns>返回0：成功；非0错误。</returns>
    private int LoginTaoBao(string username, string password,ref CookieContainer myCC, ref string errMsg)
    {
        if (username == null || username.Length == 0 || password == null || password.Length == 0)
        {
            errMsg = "用户名和密码都不能为空。";
            return 1;
        }
        Encoding myEncoding = Encoding.GetEncoding("GB2312");
        //构造提交参数
        string param = HttpUtility.UrlEncode("TPL_username", myEncoding) + "=" + HttpUtility.UrlEncode(username, myEncoding) +
            "&" + HttpUtility.UrlEncode("TPL_password", myEncoding) + "=" + HttpUtility.UrlEncode(password, myEncoding) + "&" +
            HttpUtility.UrlEncode("Submit", myEncoding) + "=" + HttpUtility.UrlEncode("登录", myEncoding) + "&" +
            HttpUtility.UrlEncode("actionForStable", myEncoding) + "=" + HttpUtility.UrlEncode("enable_post_user_action", myEncoding) + "&" +
            HttpUtility.UrlEncode("action", myEncoding) + "=" + HttpUtility.UrlEncode("Authenticator", myEncoding) + "&" +
            HttpUtility.UrlEncode("TPL_redirect_url", myEncoding) + "=" + HttpUtility.UrlEncode("_oooo_", myEncoding) + "&" +
            HttpUtility.UrlEncode("event_submit_do_login", myEncoding) + "=" + HttpUtility.UrlEncode("anything", myEncoding) + "&" +
            HttpUtility.UrlEncode("abtest", myEncoding) + "=&" + HttpUtility.UrlEncode("pstrong", myEncoding) + "=3&from=&yparam=&done=";
        byte[] postData = Encoding.ASCII.GetBytes(param);

        //准备提交
        HttpWebRequest myRequest = (HttpWebRequest)HttpWebRequest.Create("http://member1.taobao.com/member/login.jhtml");
        myRequest.Method = "POST";
        myRequest.ContentType = "application/x-www-form-urlencoded";
        myRequest.ContentLength = postData.Length;
        myRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)";
        //提交数据
        using (Stream myStream = myRequest.GetRequestStream())
        {
            myStream.Write(postData, 0, postData.Length);
            myStream.Close();
        }
        //保存cookie
        myCC = new CookieContainer();
        myRequest.CookieContainer = myCC;

        //接收服务器返回
        using (HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse())
        {
            myCC.Add(myResponse.Cookies);
            //判断密码是否正确
            if (myResponse.ResponseUri.AbsoluteUri.Contains("http://member1.taobao.com/member/login.jhtml"))
            {
                Stream resStream = myResponse.GetResponseStream();
                string webContent = new StreamReader(resStream, myEncoding).ReadToEnd();
                errMsg = webContent.Substring(webContent.IndexOf("<p class=\"ErrorMsg\">") + 20);
                errMsg = errMsg.Remove(errMsg.IndexOf("<")).Replace("\t", "").Replace("\n", "").Replace(" ", "");
                return 2;
            }
        }
        return 0;
    }
    /// <summary>
    /// 确定使用第三方应用，默认时间为1小时
    /// </summary>
    /// <param name="myCC">用户登陆后获取的cookie</param>
    /// <param name="sessionId">登录后的sessionId</param>
    /// <param name="appkey"></param>
    private void Do3thApp(CookieContainer myCC, string sessionId, string appkey)
    {
        string sessionUrl = "http://sip.alisoft.com/sip/login?sip_apiname=taobao.item.add&sip_appkey=" + appkey + "&sip_sessionid=" + sessionId + "&sip_apptype=2";
        HttpWebRequest myRequest = (HttpWebRequest)HttpWebRequest.Create(sessionUrl);
        myRequest.CookieContainer = myCC;
        HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
        myCC.Add(myResponse.Cookies);       
        
        //从url获取参数
        string resUrl = myResponse.ResponseUri.AbsoluteUri;
        HttpRequest httpRequest = new HttpRequest("url", resUrl, resUrl.Substring(resUrl.IndexOf("?") + 1));
        string strTarget = httpRequest.Params["target"];
        string strSignAccount = httpRequest.Params["signAccount"];
        string strCheck = "true";
        string strTargetSign = httpRequest.Params["targetSign"];

        //确定使用第三方服务，默认服务有效期：1小时       
        string tokenUrl = "http://auth.api.taobao.com/top-auth/session/create";
        myRequest = (HttpWebRequest)HttpWebRequest.Create(tokenUrl);
        Encoding myEncoding = Encoding.GetEncoding("gb2312");
        string param = HttpUtility.UrlEncode("sip_tokenttl", myEncoding) + "=" + HttpUtility.UrlEncode("3600", myEncoding) + "&" +
            HttpUtility.UrlEncode("target", myEncoding) + "=" + HttpUtility.UrlEncode(strTarget, myEncoding) + "&" +
            HttpUtility.UrlEncode("signAccount", myEncoding) + "=" + HttpUtility.UrlEncode(strSignAccount, myEncoding) + "&" +
            HttpUtility.UrlEncode("check", myEncoding) + "=" + HttpUtility.UrlEncode(strCheck, myEncoding) + "&" +
            HttpUtility.UrlEncode("targetSign", myEncoding) + "=" + HttpUtility.UrlEncode(strTargetSign, myEncoding);

        byte[] postData = Encoding.ASCII.GetBytes(param);
        myRequest.Method = "POST";
        myRequest.ContentType = "application/x-www-form-urlencoded";
        myRequest.ContentLength = postData.Length;
        myRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)";
        //send
        using (Stream myStream = myRequest.GetRequestStream())
        {
            myStream.Write(postData, 0, postData.Length);
            myStream.Close();
        }
        myResponse = (HttpWebResponse)myRequest.GetResponse();
        myCC.Add(myResponse.Cookies);     
    }
    /// <summary>
    /// 获取sessionid(从cookie或登陆淘宝获取)
    /// </summary>
    /// <param name="page"></param>
    /// <param name="username"></param>
    /// <param name="password"></param>
    /// <param name="appkey"></param>
    /// <param name="errMsg"></param>
    /// <param name="sessionId"></param>
    /// <returns>0：成功；非0：失败。</returns>
    public int GetTBSessionId(Page page, string username, string password, string appkey, ref string errMsg, ref string sessionId)
    {
        HttpCookie myCookie = page.Request.Cookies[username];
        if (myCookie == null)
        {
            CookieContainer myCC = new CookieContainer();
            //int ret = LoginTaoBao(username, password, ref myCC, ref errMsg);
            //if (ret != 0)
            //    return ret;

            string sqlstring = "select * from tb_appcode where field1 is  not null and field2 = '" + username + "'";//根据淘宝用户名查询淘宝网AppKey,SessionKey,AppSecret
            DataSet ds = DBUtility.SqlHelper.Query(DBUtility.SqlHelper.LocalSqlServer, sqlstring);
            sessionId = ds.Tables[0].Rows[0]["field1"].ToString();
            //sessionId = Guid.NewGuid().ToString();
            //Do3thApp(myCC, sessionId, appkey);
            //写入cookie
            myCookie = new HttpCookie(username);
            myCookie.Value = sessionId;
            myCookie.Expires = DateTime.Now.AddMinutes(30);
            page.Response.Cookies.Add(myCookie);
        }
        else
        {
            sessionId = myCookie.Value;
        }
        return 0;
    }    

    /// <summary>
    /// 添加商品到淘宝，apptype=2
    /// </summary>
    /// <param name="username"></param>
    /// <param name="password"></param>
    /// <param name="appkey"></param>
    /// <param name="certcode"></param>
    /// <param name="param"></param>
    /// <param name="img">产品图片</param>
    /// <param name="errMsg">出错信息</param>
    /// <param name="sessionId">登陆后的sessionId</param>
    /// <param name="addBus">返回数据（商品id和创建时间）</param>
    /// <returns>0：成功；非0：失败。</returns>
    public int AddItem2TaoBao(string username, string password, string appkey, string certcode, string[,] param, byte[] img, ref string errMsg,string sessionId,
        ref BS2.BSTaobaoAPI.BSTaobaoItemAddBus addBus)
    {       
        try
        { 
            BS2.BSTaobaoAPI.TaobaoAPI.setAPPID(appkey);
            BS2.BSTaobaoAPI.TaobaoAPI.setCERTCODE(certcode);
            BS2.BSTaobaoAPI.TaobaoAPI.setLoginPro(username, password);
            BS2.BSTaobaoAPI.TaobaoAPI.setSessionID(sessionId);
            
            addBus = BS2.BSTaobaoAPI.BSTaobaoBussinessAPI.getTaobaoBaobeiAdd(param, img, appkey, certcode, sessionId);
            return 0;
        }
        catch(Exception ex)
        {
            errMsg = ex.Message;
        }
        return 1;
    }
    /// <summary>
    /// 更新淘宝商品，apptype=2
    /// </summary>
    /// <param name="username"></param>
    /// <param name="password"></param>
    /// <param name="appkey"></param>
    /// <param name="certcode"></param>
    /// <param name="param"></param>
    /// <param name="img">产品图片</param>
    /// <param name="errMsg">出错信息</param>
    /// <param name="sessionId">登陆后的sessionId</param>
    /// <param name="updateBus">返回数据</param>
    /// <returns>0：成功；非0：失败。</returns>
    public int UpdateItem2TaoBao(string username, string password, string appkey, string certcode, string[,] param, byte[] img, ref string errMsg, ref string sessionId,
        BS2.BSTaobaoAPI.BSTaobaoItemUpdateBus updateBus)
    {
        try
        {           
            BS2.BSTaobaoAPI.TaobaoAPI.setAPPID(appkey);
            BS2.BSTaobaoAPI.TaobaoAPI.setCERTCODE(certcode);
            BS2.BSTaobaoAPI.TaobaoAPI.setLoginPro(username, password);
            BS2.BSTaobaoAPI.TaobaoAPI.setSessionID(sessionId);

            updateBus = BS2.BSTaobaoAPI.BSTaobaoBussinessAPI.getTaobaoBaobeiUpdate(param, img, appkey, certcode, sessionId);
            return 0;
        }
        catch (Exception ex)
        {
            errMsg = ex.Message;
        }
        return 1;
    }
    /// <summary>
    /// 返回淘宝地区
    /// </summary>
    /// <returns></returns>
    public string[,] GetTBArea()
    {
        return new string[,] { 
        { "10001", "安徽", "10001" }, { "10002", "合肥, 合肥,", "10001" }, { "10003", "安庆, 安庆,", "10001" }, { "10004", "蚌埠, 蚌埠,", "10001" }, { "10005", "亳州, 亳州,", "10001" }, { "10006", "巢湖, 巢湖,", "10001" }, { "10007", "滁州, 滁州,", "10001" }, { "10008", "阜阳, 阜阳,", "10001" }, { "10009", "贵池, 贵池,", "10001" }, { "10010", "淮北, 淮北,", "10001" }, { "10011", "淮化, 淮化,", "10001" }, { "10012", "淮南, 淮南,", "10001" }, { "10013", "黄山, 黄山,", "10001" }, { "10014", "九华山, 九华山,", "10001" }, { "10015", "六安, 六安,", "10001" }, { "10016", "马鞍山, 马鞍山,", "10001" }, 
        { "10017", "宿州, 宿州,", "10001" }, { "10018", "铜陵, 铜陵,", "10001" }, { "10019", "屯溪, 屯溪,", "10001" }, { "10020", "芜湖, 芜湖,", "10001" }, { "10021", "宣城, 宣城", "10001" }, { "20001", "北京", "20001" },{ "20002", "北京, 北京, ", "20001" }, { "30001", "重庆", "30001" },{ "30002", "重庆, 重庆, ", "30001" }, { "40001", "福建", "40001" }, { "40002", "福州, 福州,", "40001" }, { "40003", "福安, 福安,", "40001" }, { "40004", "龙岩, 龙岩,", "40001" }, { "40005", "南平, 南平,", "40001" }, { "40006", "宁德, 宁德,", "40001" }, { "40007", "莆田, 莆田,", "40001" }, { "40008", "泉州, 泉州,", "40001" }, { "40009", "三明, 三明,", "40001" }, 
        { "40010", "邵武, 邵武,", "40001" }, { "40011", "石狮, 石狮,", "40001" }, { "40012", "永安, 永安,", "40001" }, { "40013", "武夷山, 武夷山,", "40001" }, { "40014", "厦门, 厦门,", "40001" }, { "40015", "漳州, 漳州", "40001" }, { "50001", "甘肃", "50001" }, { "50002", "兰州, 兰州,", "50001" }, { "50003", "白银, 白银,", "50001" }, { "50004", "定西, 定西,", "50001" }, { "50005", "敦煌, 敦煌,", "50001" }, { "50006", "甘南, 甘南,", "50001" }, { "50007", "金昌, 金昌,", "50001" }, { "50008", "酒泉, 酒泉,", "50001" }, { "50009", "临夏, 临夏,", "50001" }, { "50010", "平凉, 平凉,", "50001" }, 
        { "50011", "天水, 天水,", "50001" }, { "50012", "武都, 武都, ", "50001" }, { "50013", "武威, 武威, ", "50001" }, { "50014", "西峰, 西峰, ", "50001" }, { "50015", "张掖, 张掖", "50001" }, { "60001", "广东", "60001" }, { "60002", "广州, 广州,", "60001" }, { "60003", "潮阳, 潮阳,", "60001" }, { "60004", "潮州, 潮州,", "60001" }, { "60005", "澄海, 澄海,", "60001" }, { "60006", "东莞, 东莞,", "60001" }, { "60007", "佛山, 佛山,", "60001" }, { "60008", "河源, 河源,", "60001" }, { "60009", "惠州, 惠州,", "60001" }, { "60010", "江门, 江门,", "60001" }, { "60011", "揭阳, 揭阳,", "60001" }, 
        { "60012", "开平, 开平,", "60001" }, { "60013", "茂名, 茂名,", "60001" }, { "60014", "梅州, 梅州,", "60001" }, { "60015", "清远, 清远,", "60001" }, { "60016", "汕头, 汕头,", "60001" }, { "60017", "汕尾, 汕尾,", "60001" }, { "60018", "韶关, 韶关,", "60001" }, { "60019", "深圳, 深圳,", "60001" }, { "60020", "顺德, 顺德,", "60001" }, { "60021", "阳江, 阳江,", "60001" }, { "60022", "英德, 英德,", "60001" }, { "60023", "云浮, 云浮,", "60001" }, { "60024", "增城, 增城,", "60001" }, { "60025", "湛江, 湛江,", "60001" }, { "60026", "肇庆, 肇庆, ", "60001" }, { "60027", "中山, 中山, ", "60001" }, 
        { "60028", "珠海, 珠海", "60001" }, { "70001", "广西", "70001" }, { "70002", "南宁, 南宁,", "70001" }, { "70003", "百色, 百色,", "70001" }, { "70004", "北海, 北海,", "70001" }, { "70005", "桂林, 桂林,", "70001" }, { "70006", "防城港, 防城港,", "70001" }, { "70007", "河池, 河池,", "70001" }, { "70008", "贺州, 贺州,", "70001" }, { "70009", "柳州, 柳州,", "70001" }, { "70010", "钦州, 钦州, ", "70001" }, { "70011", "梧州, 梧州, ", "70001" }, { "70012", "玉林, 玉林", "70001" }, { "80001", "贵州", "80001" }, { "80002", "贵阳, 贵阳,", "80001" }, { "80003", "安顺, 安顺,", "80001" }, 
        { "80004", "毕节, 毕节,", "80001" }, { "80005", "都匀, 都匀,", "80001" }, { "80006", "凯里, 凯里,", "80001" }, { "80007", "六盘水, 六盘水,", "80001" }, { "80008", "铜仁, 铜仁,", "80001" }, { "80009", "兴义, 兴义, ", "80001" }, { "80010", "玉屏, 玉屏, ", "80001" }, { "80011", "遵义, 遵义", "80001" }, { "90001", "海南", "90001" }, { "90002", "海口, 海口,", "90001" }, { "90003", "儋县, 儋县,", "90001" }, { "90004", "陵水, 陵水,", "90001" }, { "90005", "琼海, 琼海,", "90001" }, { "90006", "三亚, 三亚, ", "90001" }, { "90007", "五指山, 五指山, ", "90001" }, { "90008", "万宁, 万宁", "90001" }, 
        { "100001", "河北", "100001" }, { "100002", "石家庄, 石家庄,", "100001" }, { "100003", "保定, 保定,", "100001" }, { "100004", "北戴河, 北戴河,", "100001" }, { "100005", "沧州, 沧州,", "100001" }, { "100006", "承德, 承德,", "100001" }, { "100007", "丰润, 丰润,", "100001" }, { "100008", "邯郸, 邯郸,", "100001" }, { "100009", "衡水, 衡水,", "100001" }, { "100010", "廊坊, 廊坊,", "100001" }, { "100011", "南戴河, 南戴河,", "100001" }, { "100012", "秦皇岛, 秦皇岛,", "100001" }, { "100013", "唐山, 唐山,", "100001" }, { "100014", "新城, 新城,", "100001" }, { "100015", "邢台, 邢台, ", "100001" }, { "100016", "张家口, 张家口", "100001" }, 
        { "110001", "黑龙江", "110001" }, { "110002", "哈尔滨, 哈尔滨,", "110001" }, { "110003", "北安, 北安,", "110001" }, { "110004", "大庆, 大庆,", "110001" }, { "110005", "大兴安岭, 大兴安岭,", "110001" }, { "110006", "鹤岗, 鹤岗,", "110001" }, { "110007", "黑河, 黑河,", "110001" }, { "110008", "佳木斯, 佳木斯,", "110001" }, { "110009", "鸡西, 鸡西,", "110001" }, { "110010", "牡丹江, 牡丹江,", "110001" }, { "110011", "齐齐哈尔, 齐齐哈尔,", "110001" }, { "110012", "七台河, 七台河,", "110001" }, { "110013", "双鸭山, 双鸭山,", "110001" }, { "110014", "绥化, 绥化,", "110001" }, { "110015", "伊春, 伊春", "110001" }, { "120001", "河南", "120001" }, 
        { "120002", "郑州, 郑州,", "120001" }, { "120003", "安阳, 安阳,", "120001" }, { "120004", "鹤壁, 鹤壁,", "120001" }, { "120005", "潢川, 潢川,", "120001" }, { "120006", "焦作, 焦作,", "120001" }, { "120007", "济源, 济源,", "120001" }, { "120008", "开封, 开封,", "120001" }, { "120009", "漯河, 漯河,", "120001" }, { "120010", "洛阳, 洛阳,", "120001" }, { "120011", "南阳, 南阳,", "120001" }, { "120012", "平顶山, 平顶山,", "120001" }, { "120013", "濮阳, 濮阳,", "120001" }, { "120014", "三门峡, 三门峡,", "120001" }, { "120015", "商丘, 商丘,", "120001" }, { "120016", "新乡, 新乡,", "120001" }, { "120017", "信阳, 信阳,", "120001" }, 
        { "120018", "许昌, 许昌,", "120001" }, { "120019", "周口, 周口, ", "120001" }, { "120020", "驻马店, 驻马店", "120001" }, { "130001", "湖北 ", "130001" }, { "130002", "武汉, 武汉,", "130001" }, { "130003", "恩施, 恩施,", "130001" }, { "130004", "鄂州, 鄂州,", "130001" }, { "130005", "黄冈, 黄冈,", "130001" }, { "130006", "黄石, 黄石,", "130001" }, { "130007", "荆门, 荆门,", "130001" }, { "130008", "荆州, 荆州,", "130001" }, { "130009", "潜江, 潜江,", "130001" }, { "130010", "十堰, 十堰,", "130001" }, { "130011", "随州, 随州,", "130001" }, { "130012", "武穴, 武穴,", "130001" }, { "130013", "仙桃, 仙桃,", "130001" }, 
        { "130014", "咸宁, 咸宁,", "130001" }, { "130015", "襄阳, 襄阳,", "130001" }, { "130016", "襄樊, 襄樊,", "130001" }, { "130017", "孝感, 孝感,", "130001" }, { "130018", "宜昌, 宜昌", "130001" }, { "140001", "湖南", "140001" }, { "140002", "长沙, 长沙,", "140001" }, { "140003", "常德, 常德,", "140001" }, { "140004", "郴州, 郴州,", "140001" }, { "140005", "衡阳, 衡阳,", "140001" }, { "140006", "怀化, 怀化,", "140001" }, { "140007", "吉首, 吉首,", "140001" }, { "140008", "娄底, 娄底,", "140001" }, { "140009", "邵阳, 邵阳,", "140001" }, { "140010", "湘潭, 湘潭,", "140001" }, { "140011", "益阳, 益阳,", "140001" }, 
        { "140012", "岳阳, 岳阳,", "140001" }, { "140013", "永州, 永州,", "140001" }, { "140014", "张家界, 张家界,", "140001" }, { "140015", "株洲, 株洲", "140001" }, { "150001", "江苏", "150001" }, { "150002", "南京, 南京,", "150001" }, { "150003", "常熟, 常熟,", "150001" }, { "150004", "常州, 常州,", "150001" }, { "150005", "海门, 海门,", "150001" }, { "150006", "淮安, 淮安,", "150001" }, { "150007", "江都, 江都,", "150001" }, { "150008", "江阴, 江阴,", "150001" }, { "150009", "昆山, 昆山,", "150001" }, { "150010", "连云港, 连云港,", "150001" }, { "150011", "南通, 南通,", "150001" }, { "150012", "启东, 启东,", "150001" }, 
        { "150013", "沭阳, 沭阳,", "150001" }, { "150014", "宿迁, 宿迁,", "150001" }, { "150015", "苏州, 苏州,", "150001" }, { "150016", "太仓, 太仓,", "150001" }, { "150017", "泰州, 泰州,", "150001" }, { "150018", "同里, 同里,", "150001" }, { "150019", "无锡, 无锡,", "150001" }, { "150020", "徐州, 徐州,", "150001" }, { "150021", "盐城, 盐城,", "150001" }, { "150022", "扬州, 扬州,", "150001" }, { "150023", "宜兴, 宜兴,", "150001" }, { "150024", "仪征, 仪征,", "150001" }, { "150025", "张家港, 张家港, ", "150001" }, { "150026", "镇江, 镇江, ", "150001" }, { "150027", "周庄, 周庄", "150001" }, { "160001", "江西", "160001" }, 
        { "160002", "南昌, 南昌,", "160001" }, { "160003", "抚州, 抚州,", "160001" }, { "160004", "赣州, 赣州,", "160001" }, { "160005", "吉安, 吉安,", "160001" }, { "160006", "景德镇, 景德镇,", "160001" }, { "160007", "井冈山, 井冈山,", "160001" }, { "160008", "九江, 九江,", "160001" }, { "160009", "庐山, 庐山,", "160001" }, { "160010", "萍乡, 萍乡,", "160001" }, { "160011", "上饶, 上饶,", "160001" }, { "160012", "新余, 新余, ", "160001" }, { "160013", "宜春, 宜春, ", "160001" }, { "160014", "鹰潭, 鹰潭", "160001" }, { "170001", "吉林", "170001" }, { "170002", "长春, 长春,", "170001" }, { "170003", "白城, 白城,", "170001" }, 
        { "170004", "白山, 白山,", "170001" }, { "170005", "珲春, 珲春,", "170001" }, { "170006", "辽源, 辽源,", "170001" }, { "170007", "梅河, 梅河,", "170001" }, { "170008", "吉林, 吉林,", "170001" }, { "170009", "四平, 四平,", "170001" }, { "170010", "松原, 松原,", "170001" }, { "170011", "通化, 通化,", "170001" }, { "170012", "延吉, 延吉", "170001" }, { "180001", "辽宁", "180001" }, { "180002", "沈阳, 沈阳,", "180001" }, { "180003", "鞍山, 鞍山,", "180001" }, { "180004", "本溪, 本溪,", "180001" }, { "180005", "朝阳, 朝阳,", "180001" }, { "180006", "大连, 大连,", "180001" }, { "180007", "丹东, 丹东,", "180001" }, 
        { "180008", "抚顺, 抚顺,", "180001" }, { "180009", "阜新, 阜新,", "180001" }, { "180010", "葫芦岛, 葫芦岛,", "180001" }, { "180011", "锦州, 锦州,", "180001" }, { "180012", "辽阳, 辽阳,", "180001" }, { "180013", "盘锦, 盘锦,", "180001" }, { "180014", "铁岭, 铁岭,", "180001" }, { "180015", "营口, 营口", "180001" }, { "190001", "内蒙古", "190001" }, { "190002", "呼和浩特, 呼和浩特,", "190001" }, { "190003", "阿拉善盟, 阿拉善盟,", "190001" }, { "190004", "包头, 包头,", "190001" }, { "190005", "赤峰, 赤峰,", "190001" }, { "190006", "东胜, 东胜,", "190001" }, { "190007", "海拉尔, 海拉尔,", "190001" }, { "190008", "集宁, 集宁,", "190001" }, 
        { "190009", "临河, 临河,", "190001" }, { "190010", "通辽, 通辽,", "190001" }, { "190011", "乌海, 乌海,", "190001" }, { "190012", "乌兰浩特, 乌兰浩特, ", "190001" }, { "190013", "锡林浩特, 锡林浩特", "190001" }, { "200001", "宁夏", "200001" }, { "200002", "银川, 银川,", "200001" }, { "200003", "固原, 固原, ", "200001" }, { "200004", "石嘴山, 石嘴山, ", "200001" }, { "200005", "吴忠, 吴忠", "200001" }, { "210001", "青海", "210001" }, { "210002", "西宁, 西宁,", "210001" }, { "210003", "德令哈, 德令哈,", "210001" }, { "210004", "格尔木, 格尔木,", "210001" }, { "210005", "共和, 共和,", "210001" }, { "210006", "海东, 海东,", "210001" }, 
        { "210007", "海晏, 海晏,", "210001" }, { "210008", "玛沁, 玛沁,", "210001" }, { "210009", "同仁, 同仁, ", "210001" }, { "210010", "玉树, 玉树", "210001" }, { "220001", "山东", "220001" }, { "220002", "济南, 济南,", "220001" }, { "220003", "滨州, 滨州,", "220001" }, { "220004", "兖州, 兖州,", "220001" }, { "220005", "德州, 德州,", "220001" }, { "220006", "东营, 东营,", "220001" }, { "220007", "菏泽, 菏泽,", "220001" }, { "220008", "济宁, 济宁,", "220001" }, { "220009", "莱芜, 莱芜,", "220001" }, { "220010", "聊城, 聊城,", "220001" }, { "220011", "临沂, 临沂,", "220001" }, { "220012", "蓬莱, 蓬莱,", "220001" }, 
        { "220013", "青岛, 青岛,", "220001" }, { "220014", "曲阜, 曲阜,", "220001" }, { "220015", "日照, 日照,", "220001" }, { "220016", "泰安, 泰安,", "220001" }, { "220017", "潍坊, 潍坊,", "220001" }, { "220018", "威海, 威海,", "220001" }, { "220019", "烟台, 烟台,", "220001" }, { "220020", "枣庄, 枣庄,", "220001" }, { "220021", "淄博, 淄博", "220001" }, { "230001", "上海", "230001" }, { "230002", "上海, 上海, ", "230001" }, { "230003", "崇明, 崇明, ", "230001" }, { "230004", "朱家角, 朱家角", "230001" }, { "240001", "山西", "240001" }, { "240002", "太原, 太原,", "240001" }, { "240003", "长治, 长治,", "240001" }, 
        { "240004", "大同, 大同,", "240001" }, { "240005", "候马, 候马,", "240001" }, { "240006", "晋城, 晋城,", "240001" }, { "240007", "离石, 离石,", "240001" }, { "240008", "临汾, 临汾,", "240001" }, { "240009", "宁武, 宁武,", "240001" }, { "240010", "朔州, 朔州,", "240001" }, { "240011", "忻州, 忻州,", "240001" }, { "240012", "阳泉, 阳泉, ", "240001" }, { "240013", "榆次, 榆次, ", "240001" }, { "240014", "运城, 运城", "240001" }, { "250001", "陕西", "250001" }, { "250002", "西安, 西安,", "250001" }, { "250003", "安康, 安康,", "250001" }, { "250004", "宝鸡, 宝鸡,", "250001" }, { "250005", "汉中, 汉中,", "250001" }, 
        { "250006", "渭南, 渭南,", "250001" }, { "250007", "商州, 商州,", "250001" }, { "250008", "绥德, 绥德,", "250001" }, { "250009", "铜川, 铜川,", "250001" }, { "250010", "咸阳, 咸阳,", "250001" }, { "250011", "延安, 延安,", "250001" }, { "250012", "榆林, 榆林", "250001" }, { "260001", "四川", "260001" }, { "260002", "成都, 成都,", "260001" }, { "260003", "巴中, 巴中,", "260001" }, { "260004", "达州, 达州,", "260001" }, { "260005", "德阳, 德阳,", "260001" }, { "260006", "都江堰, 都江堰,", "260001" }, { "260007", "峨眉山, 峨眉山,", "260001" }, { "260008", "涪陵, 涪陵,", "260001" }, { "260009", "广安, 广安,", "260001" }, 
        { "260010", "广元, 广元,", "260001" }, { "260011", "九寨沟, 九寨沟,", "260001" }, { "260012", "康定, 康定,", "260001" }, { "260013", "乐山, 乐山,", "260001" }, { "260014", "泸州, 泸州,", "260001" }, { "260015", "马尔康, 马尔康,", "260001" }, { "260016", "绵阳, 绵阳,", "260001" }, { "260017", "眉山, 眉山,", "260001" }, { "260018", "南充, 南充,", "260001" }, { "260019", "内江, 内江,", "260001" }, { "260020", "攀枝花, 攀枝花,", "260001" }, { "260021", "遂宁, 遂宁,", "260001" }, { "260022", "汶川, 汶川,", "260001" }, { "260023", "西昌, 西昌,", "260001" }, { "260024", "雅安, 雅安,", "260001" }, { "260025", "宜宾, 宜宾, ", "260001" }, 
        { "260026", "自贡, 自贡,", "260001" }, { "260027", "资阳, 资阳", "260001" }, { "270001", "天津", "270001" }, { "270002", "天津, 天津, ", "270001" },{ "280001", "新疆", "280001" }, { "280002", "乌鲁木齐, 乌鲁木齐,", "280001" }, { "280003", "阿克苏, 阿克苏,", "280001" }, { "280004", "阿勒泰, 阿勒泰,", "280001" }, { "280005", "阿图什, 阿图什,", "280001" }, { "280006", "博乐, 博乐,", "280001" }, { "280007", "昌吉, 昌吉,", "280001" }, { "280008", "东山, 东山,", "280001" }, { "280009", "哈密, 哈密,", "280001" }, { "280010", "和田, 和田,", "280001" }, { "280011", "喀什, 喀什,", "280001" }, { "280012", "克拉玛依, 克拉玛依,", "280001" }, { "280013", "库车, 库车,", "280001" }, 
        { "280014", "库尔勒, 库尔勒,", "280001" }, { "280015", "奎屯, 奎屯,", "280001" }, { "280016", "石河子, 石河子,", "280001" }, { "280017", "塔城, 塔城,", "280001" }, { "280018", "吐鲁番, 吐鲁番, ", "280001" }, { "280019", "伊宁, 伊宁", "280001" }, { "290001", "西藏", "290001" }, { "290002", "拉萨, 拉萨,", "290001" }, { "290003", "阿里, 阿里,", "290001" }, { "290004", "昌都, 昌都,", "290001" }, { "290005", "林芝, 林芝,", "290001" }, { "290006", "那曲, 那曲, ", "290001" }, { "290007", "日喀则, 日喀则, ", "290001" }, { "290008", "山南, 山南", "290001" }, { "300001", "云南", "300001" }, { "300002", "昆明, 昆明,", "300001" }, 
        { "300003", "大理, 大理,", "300001" }, { "300004", "保山, 保山,", "300001" }, { "300005", "楚雄, 楚雄,", "300001" }, { "300006", "大理, 大理,", "300001" }, { "300007", "东川, 东川,", "300001" }, { "300008", "个旧, 个旧,", "300001" }, { "300009", "景洪, 景洪,", "300001" }, { "300010", "开远, 开远,", "300001" }, { "300011", "临沧, 临沧,", "300001" }, { "300012", "丽江, 丽江,", "300001" }, { "300013", "六库, 六库,", "300001" }, { "300014", "潞西, 潞西,", "300001" }, { "300015", "曲靖, 曲靖,", "300001" }, { "300016", "思茅, 思茅,", "300001" }, { "300017", "文山, 文山,", "300001" }, { "300018", "西双版纳, 西双版纳,", "300001" }, 
        { "300019", "玉溪, 玉溪, ", "300001" }, { "300020", "中甸, 中甸, ", "300001" }, { "300021", "昭通, 昭通", "300001" }, { "310001", "浙江", "310001" }, { "310002", "杭州, 杭州,", "310001" }, { "310003", "安吉, 安吉,", "310001" }, { "310004", "慈溪, 慈溪,", "310001" }, { "310005", "定海, 定海,", "310001" }, { "310006", "奉化, 奉化,", "310001" }, { "310007", "海盐, 海盐,", "310001" }, { "310008", "黄岩, 黄岩,", "310001" }, { "310009", "湖州, 湖州,", "310001" }, { "310010", "嘉兴, 嘉兴,", "310001" }, { "310011", "金华, 金华,", "310001" }, { "310012", "临安, 临安,", "310001" }, { "310013", "临海, 临海,", "310001" }, 
        { "310014", "丽水, 丽水,", "310001" }, { "310015", "宁波, 宁波,", "310001" }, { "310016", "瓯海, 瓯海,", "310001" }, { "310017", "平湖, 平湖,", "310001" }, { "310018", "千岛湖, 千岛湖,", "310001" }, { "310019", "衢州, 衢州,", "310001" }, { "310020", "江山, 江山,", "310001" }, { "310021", "瑞安, 瑞安,", "310001" }, { "310022", "绍兴, 绍兴,", "310001" }, { "310023", "嵊州, 嵊州,", "310001" }, { "310024", "台州, 台州,", "310001" }, { "310025", "温岭, 温岭,", "310001" }, { "310026", "温州, 温州,", "310001" }, { "310027", "舟山, 舟山", "310001" }, { "320001", "香港", "320001" }, { "320002", "香港, 香港, ", "320001" }, 
        { "320003", "九龙, 九龙,", "320001" }, { "320004", "新界, 新界", "320001" }, { "330001", "澳门", "330001" }, { "330002", "澳门, 澳门", "330001" }, { "340001", "台湾", "340001" }, { "340002", "台北, 台北,", "340001" }, { "340003", "基隆, 基隆, ", "340001" }, { "340004", "台南, 台南, ", "340001" }, { "340005", "台中, 台中,", "340001" }, { "340006", "新竹, 新竹,", "340001" }, { "340007", "嘉义, 嘉义,", "340001" }, { "340008", "高雄, 高雄,", "340001" }, { "340009", "金门县,金门县,", "340001" }, { "340010", "其它, 其它", "340001" }, { "350001", " 海外 ", "350001" }, { "350002", "美国, 美国,", "350001" }, 
        { "350003", "英国, 英国, ", "350001" }, { "350004", "法国, 法国, ", "350001" }, { "350005", "瑞士, 瑞士, ", "350001" }, { "350006", "澳洲, 澳洲, ", "350001" }, { "350007", "新西兰, 新西兰, ", "350001" }, { "350008", "加拿大, 加拿大, ", "350001" }, { "350009", "奥地利, 奥地利, ", "350001" }, { "350010", "韩国, 韩国, ", "350001" }, { "350011", "日本, 日本, ", "350001" }, { "350012", "德国, 德国, ", "350001" }, { "350013", "其它国家, 其它国家", "350001" }
     };
    }
            
}
